*****2016 ANES Time-Series Manipulation*****

 gen weight=V160102
 
 
 gen age=V161267
 replace age=. if V161267<0
 
 gen republican= V161158x-1
 replace republican=. if V161158x<0
 
 gen strength=.
 replace strength=0 if republican==3
 replace strength=1 if republican==2 | republican==4
 replace strength=2 if republican==1 | republican==5
 replace strength=3 if republican==0 | republican==6
 
 gen race= V161310x
 replace race=. if  V161310x<0
 label var race "1=white 2=Black 3=Asian 4=NA 5=Hispanic"
 
 gen nonwhite=1
 replace nonwhite=0 if race==1
 
 
 gen interest=V162256-1
 replace interest=. if V162256<0
 recode interest (0=3) (1=2) (2=1) (3=0)
 
 gen female=.
 replace female=0 if V161342==1
 replace female=1 if V161342==2
 
 gen conservative=V161126-1
 replace conservative=. if V161126<0
 recode conservative (98=3)
 
 gen education=V161270-1
 replace education=. if V161270<0
 replace education=. if V161270>15
 
 
 gen trumpfeels=V162079
 replace trumpfeels=. if V162079<0
 replace trumpfeels=. if V162079==998
 
 
 
 ***Americanism***
 gen bornus=V162271-1
 replace bornus=. if V162271<0
 recode bornus (0=3)(1=2)(2=1)(3=0)
 
 gen ancestry=V162272-1
 replace ancestry=. if V162272<0
 recode ancestry (0=3)(1=2)(2=1)(3=0)
 
 gen english= V162273-1
 replace english=. if  V162273<0
 recode english (0=3)(1=2)(2=1)(3=0) 
 
 gen traditions=V162274-1
 replace traditions=. if V162274<0
 recode traditions (0=3)(1=2)(2=1)(3=0) 

 gen culture_threat=V162269-1
 replace culture_threat=. if V162269<0
 recode culture_threat (0=4)(1=3)(2=2)(3=1)(4=0) 
 
 gen assimilate=V162266-1
 replace assimilate=. if V162266<0
 recode assimilate (0=4)(1=3)(2=2)(3=1)(4=0)
 
 gen immigrants_good= V162268-1
 replace immigrants_good=. if V162268<0
 
 gen nativism= (bornus+english+traditions+ancestry)
 
 
 recode republican (0/2=0)(3=1)(4/6=2), gen(gop3)
 
 gen demlike=V162283
 replace demlike=. if demlike<0
 
 gen goplike=V162284
 replace goplike=. if goplike<0
 
 
  gen dem_feels= V161095
 replace dem_feels=. if V161095<0
 
 gen gop_feels= V161096
 replace gop_feels=. if V161096<0
 
 gen outparty_feels=.
 replace outparty_feels=gop_feels if gop3==0
 replace outparty_feels=dem_feels if gop3==2
 
 gen outparty_like=.
 replace outparty_like=goplike if gop3==0
 replace outparty_like=demlike if gop3==2
 
 gen gop2=.
 replace gop2=0 if gop3==0
 replace gop2=1 if gop3==2
 
 gen polarization=abs(outparty_like-10)
 
 ***Racial Resentment***
 gen specialfavors=V162211-1
 replace specialfavors=. if specialfavors<0
 recode specialfavors (0=4)(1=3)(2=2)(3=1)(4=0)
 
 gen slavery=V162212-1
 replace slavery=. if slavery<0
 
 gen tryharder=V162214-1
 replace tryharder=. if tryharder<0
 recode tryharder (0=4)(1=3)(2=2)(3=1)(4=0)
 
 gen gottenless=V162213-1
 replace gottenless=. if gottenless<0
 
  gen resentment= (specialfavors+slavery+tryharder+gottenless)
 

 **Analysis**
 
 alpha bornus ancestry english traditions if race==1, item

 
 alpha bornus ancestry english traditions if race==1 & gop2==0, item
  alpha bornus ancestry english traditions if race==1 & gop2==1, item
 
 
factor bornus ancestry english traditions if race==1 & gop2==1, pcf
rotate, promax blanks (.4)
estat common sum polarization if race==1, d
 
 
 corr nativism republican if race==1 [aweight=V160102]
 
 reg nativism gop2 if race==1 [pw= V160102]
 

  twoway (kdensity nativism if gop3==0 & race==1)(kdensity nativism if gop3==2 & race==1)

  reg polarization educ female age interest conservative strength c.gop2##c.nativism if race==1 [pw=V160102]
  
 
  
  